<!doctype html>



  


<html class="theme-next mist use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="baidu-site-verification" content="zD47G9xe42" />


<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="uiste个人博客网站,uiste,uiste博客,PHP,运维,Hexo,技术博客" />





  <link rel="alternate" href="/atom.xml" title="uiste" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta name="description" content="Stay Hungry，Stay Foolish">
<meta property="og:type" content="website">
<meta property="og:title" content="uiste">
<meta property="og:url" content="http://blog.uiste.com/page/4/index.html">
<meta property="og:site_name" content="uiste">
<meta property="og:description" content="Stay Hungry，Stay Foolish">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="uiste">
<meta name="twitter:description" content="Stay Hungry，Stay Foolish">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>




  <link rel="canonical" href="http://blog.uiste.com/page/4/"/>

  <title>
 
  uiste - Stay Hungry，Stay Foolish 

</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?b58b87af012832b8ae35e33bb45b44fa";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left 
   page-home 
 ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">uiste</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">uiste个人博客</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      

            <li class="menu-item menu-item-search"> <a title="把这个链接拖到你的Chrome收藏夹工具栏中" href='javascript:(function() {
    function c() {
        var e = document.createElement("link");
        e.setAttribute("type", "text/css");
        e.setAttribute("rel", "stylesheet");
        e.setAttribute("href", f);
        e.setAttribute("class", l);
        document.body.appendChild(e)
    }
 
    function h() {
        var e = document.getElementsByClassName(l);
        for (var t = 0; t < e.length; t++) {
            document.body.removeChild(e[t])
        }
    }
 
    function p() {
        var e = document.createElement("div");
        e.setAttribute("class", a);
        document.body.appendChild(e);
        setTimeout(function() {
            document.body.removeChild(e)
        }, 100)
    }
 
    function d(e) {
        return {
            height : e.offsetHeight,
            width : e.offsetWidth
        }
    }
 
    function v(i) {
        var s = d(i);
        return s.height > e && s.height < n && s.width > t && s.width < r
    }
 
    function m(e) {
        var t = e;
        var n = 0;
        while (!!t) {
            n += t.offsetTop;
            t = t.offsetParent
        }
        return n
    }
 
    function g() {
        var e = document.documentElement;
        if (!!window.innerWidth) {
            return window.innerHeight
        } else if (e && !isNaN(e.clientHeight)) {
            return e.clientHeight
        }
        return 0
    }
 
    function y() {
        if (window.pageYOffset) {
            return window.pageYOffset
        }
        return Math.max(document.documentElement.scrollTop, document.body.scrollTop)
    }
 
    function E(e) {
        var t = m(e);
        return t >= w && t <= b + w
    }
 
    function S() {
        var e = document.createElement("audio");
        e.setAttribute("class", l);
        e.src = i;
        e.loop = false;
        e.addEventListener("canplay", function() {
            setTimeout(function() {
                x(k)
            }, 500);
            setTimeout(function() {
                N();
                p();
                for (var e = 0; e < O.length; e++) {
                    T(O[e])
                }
            }, 15500)
        }, true);
        e.addEventListener("ended", function() {
            N();
            h()
        }, true);
        e.innerHTML = " <p>If you are reading this, it is because your browser does not support the audio element. We recommend that you get a new browser.</p> <p>";
        document.body.appendChild(e);
        e.play()
    }
 
    function x(e) {
        e.className += " " + s + " " + o
    }
 
    function T(e) {
        e.className += " " + s + " " + u[Math.floor(Math.random() * u.length)]
    }
 
    function N() {
        var e = document.getElementsByClassName(s);
        var t = new RegExp("\\b" + s + "\\b");
        for (var n = 0; n < e.length; ) {
            e[n].className = e[n].className.replace(t, "")
        }
    }
 
    var e = 30;
    var t = 30;
    var n = 350;
    var r = 350;
    var i = "//s3.amazonaws.com/moovweb-marketing/playground/harlem-shake.mp3";
    var s = "mw-harlem_shake_me";
    var o = "im_first";
    var u = ["im_drunk", "im_baked", "im_trippin", "im_blown"];
    var a = "mw-strobe_light";
    var f = "//s3.amazonaws.com/moovweb-marketing/playground/harlem-shake-style.css";
    var l = "mw_added_css";
    var b = g();
    var w = y();
    var C = document.getElementsByTagName("*");
    var k = null;
    for (var L = 0; L < C.length; L++) {
        var A = C[L];
        if (v(A)) {
            if (E(A)) {
                k = A;
                break
            }
        }
    }
    if (A === null) {
        console.warn("Could not find a node of the right size. Please try a different page.");
        return
    }
    c();
    S();
    var O = [];
    for (var L = 0; L < C.length; L++) {
        var A = C[L];
        if (v(A)) {
            O.push(A)
        }
    }
})()    '>High</a> </li>

    </ul>
  

 
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
   
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/20161004-1.html" itemprop="url">
                  PHP环境LAMP/LNMP安装与配置
                </a>
              
            
          </h1>
        

        <div class="post-meta">
        
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-10-04T18:42:35+08:00" content="2016-10-04">
              2016-10-04
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/20161004-1.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="20161004-1.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>虚拟机安装略过</p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/20161001-1.html" itemprop="url">
                  Laravel - 表单操作
                </a>
              
            
          </h1>
        

        <div class="post-meta">
        
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-10-01T01:17:43+08:00" content="2016-10-01">
              2016-10-01
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/20161001-1.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="20161001-1.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="静态资源管理及模板布局"><a href="#静态资源管理及模板布局" class="headerlink" title="静态资源管理及模板布局"></a>静态资源管理及模板布局</h1><h1 id="表单列表及分页实现"><a href="#表单列表及分页实现" class="headerlink" title="表单列表及分页实现"></a>表单列表及分页实现</h1><h1 id="通过表单实现新增及操作状态提示功能"><a href="#通过表单实现新增及操作状态提示功能" class="headerlink" title="通过表单实现新增及操作状态提示功能"></a>通过表单实现新增及操作状态提示功能</h1><p>设置成功之后有提示？<br>使用session的暂存数据，也就是flash，跟上一个with即可？？？</p>
<h1 id="表单验证及数据保持详解"><a href="#表单验证及数据保持详解" class="headerlink" title="表单验证及数据保持详解"></a>表单验证及数据保持详解</h1><p>控制器验证<br>Validator<br>数据保持</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div></pre></td><td class="code"><pre><div class="line">//添加学生信息</div><div class="line">	//接收表单提交数据-create方法</div><div class="line">	public function create(Request $request)&#123;</div><div class="line">		if($request-&gt;isMethod(&apos;POST&apos;))&#123;</div><div class="line">			//表单验证必填项，最小2个字符，最大20字符</div><div class="line">			$this-&gt;validate($request,[</div><div class="line">				&apos;student.name&apos;	=&gt;	&apos;required|min:2|max:20&apos;,</div><div class="line">				&apos;student.age&apos;	=&gt;	&apos;required|integer&apos;,</div><div class="line">				&apos;student.sex&apos;	=&gt;	&apos;required|integer&apos;</div><div class="line">			]);</div><div class="line">			$data = $request-&gt;input(&apos;student&apos;);</div><div class="line">//			保存提交数据方法一</div><div class="line">//			$student = new Student();</div><div class="line">//			$student-&gt;name = $data[&apos;name&apos;];</div><div class="line">//			$student-&gt;age = $data[&apos;age&apos;];</div><div class="line">//			$student-&gt;sex = $data[&apos;sex&apos;];</div><div class="line">//			if($student-&gt;save())</div><div class="line">			if(Student::create($data))</div><div class="line">				return redirect(&apos;student/index&apos;)-&gt;with(&apos;success&apos;,&apos;添加成功&apos;);</div><div class="line">//				return redirect(&apos;student/index&apos;);</div><div class="line">			return redirect()-&gt;back();</div><div class="line">		&#125;</div><div class="line">		return view(&apos;student.create&apos;);</div><div class="line">	&#125;</div></pre></td></tr></table></figure>
<h1 id="通过模型处理性别"><a href="#通过模型处理性别" class="headerlink" title="通过模型处理性别"></a>通过模型处理性别</h1><h1 id="通过表单实现修改"><a href="#通过表单实现修改" class="headerlink" title="通过表单实现修改"></a>通过表单实现修改</h1><h1 id="表单中查看详情及删除"><a href="#表单中查看详情及删除" class="headerlink" title="表单中查看详情及删除"></a>表单中查看详情及删除</h1>
          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/20160930-4.html" itemprop="url">
                  laravel - 控制器基础
                </a>
              
            
          </h1>
        

        <div class="post-meta">
        
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-09-30T19:20:46+08:00" content="2016-09-30">
              2016-09-30
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/20160930-4.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="20160930-4.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>路径：<code>app/Http/Controllers</code></p>
<h1 id="基础控制器"><a href="#基础控制器" class="headerlink" title="基础控制器"></a>基础控制器</h1><figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span> <span class="keyword">namespace</span> <span class="title">App</span>\<span class="title">Http</span>\<span class="title">Controllers</span>;</div><div class="line"></div><div class="line"><span class="keyword">use</span> <span class="title">App</span>\<span class="title">Http</span>\<span class="title">Controllers</span>\<span class="title">Controller</span>;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">UserController</span> <span class="keyword">extends</span> <span class="title">Controller</span> </span>&#123;</div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 显示所给定的用户个人数据。</div><div class="line">     *</div><div class="line">     * <span class="doctag">@param</span>  int  $id</div><div class="line">     * <span class="doctag">@return</span> Response</div><div class="line">     */</div><div class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">showProfile</span><span class="params">($id)</span></span></div><div class="line">    &#123;</div><div class="line">        <span class="keyword">return</span> view(<span class="string">'user.profile'</span>, [<span class="string">'user'</span> =&gt; User::findOrFail($id)]);</div><div class="line">    &#125;</div><div class="line"></div><div class="line">&#125;</div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<blockquote>
<p>可以通过如下方式引导路由至对应的控制器动作：<br><code>Route::any(&#39;test1&#39;,[&#39;uses&#39;=&gt;&#39;StudentController@test1&#39;]);</code></p>
</blockquote>
<h1 id="Controller之Request"><a href="#Controller之Request" class="headerlink" title="Controller之Request"></a>Controller之Request</h1><h1 id="Controller之Session"><a href="#Controller之Session" class="headerlink" title="Controller之Session"></a>Controller之Session</h1><h1 id="Controller之Response"><a href="#Controller之Response" class="headerlink" title="Controller之Response"></a>Controller之Response</h1><h1 id="Controller之Middleware"><a href="#Controller之Middleware" class="headerlink" title="Controller之Middleware"></a>Controller之Middleware</h1><p>laravel中间件提供一个方便的机制来过滤进入应用程序的HTTP请求</p>
<h3 id="第一步新建中间件"><a href="#第一步新建中间件" class="headerlink" title="第一步新建中间件"></a>第一步新建中间件</h3><p><code>Middleware=&gt;Activity.php</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line">&lt;?php </div><div class="line">namespace App\Http\Middleware;</div><div class="line">use closure;</div><div class="line">class Activity&#123;</div><div class="line">    //新建一个固定的方法handle($request,$next);</div><div class="line">    //next 是一个全局的包</div><div class="line">    //请求执行前操作，前置操作</div><div class="line">    //$next($request)响应</div><div class="line">    public function handle($request,$next)&#123;</div><div class="line">        if (time()&lt;strtotime(&apos;2016-10-2&apos;)) &#123;</div><div class="line">            return redirect(&apos;activity0&apos;);</div><div class="line">        &#125;</div><div class="line">        return $next($request);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line">?&gt;</div></pre></td></tr></table></figure>
<h3 id="第二步注册中间件"><a href="#第二步注册中间件" class="headerlink" title="第二步注册中间件"></a>第二步注册中间件</h3><p><code>Kernel.php=&gt;protected $routeMiddleware</code></p>
<p><code>&#39;activity&#39; =&gt; \App\Http\Middleware\Activity::class</code></p>
<h3 id="第三步使用中间件"><a href="#第三步使用中间件" class="headerlink" title="第三步使用中间件"></a>第三步使用中间件</h3><p><code>routes.php</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">    Route::any(&apos;activity0&apos;,[&apos;uses&apos;=&gt;&apos;StudentController@activity0&apos;]);</div><div class="line">    //使用中间件</div><div class="line">    Route::group([&apos;middleware&apos;=&gt;&apos;activity&apos;],function()&#123;</div><div class="line">        Route::any(&apos;activity1&apos;,[&apos;uses&apos;=&gt;&apos;StudentController@activity1&apos;]);</div><div class="line">        Route::any(&apos;activity2&apos;,[&apos;uses&apos;=&gt;&apos;StudentController@activity2&apos;]);</div><div class="line">&#125;);</div></pre></td></tr></table></figure>
<p>补充StudentController：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">public function activity0()&#123;</div><div class="line">        return &apos;活动快要开始了，敬请期待&apos;;</div><div class="line">    &#125;</div><div class="line">    public function activity1()&#123;</div><div class="line">        return &apos;活动进行中，谢谢您的参与&apos;;</div><div class="line">    &#125;</div><div class="line">    public function activity2()&#123;</div><div class="line">        return &apos;活动仍在进行中，谢谢参与&apos;;</div><div class="line">    &#125;</div></pre></td></tr></table></figure>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/20160930-3.html" itemprop="url">
                  laravel - 路由基础
                </a>
              
            
          </h1>
        

        <div class="post-meta">
        
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-09-30T19:01:27+08:00" content="2016-09-30">
              2016-09-30
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/20160930-3.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="20160930-3.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>laravel框架与传统框架的不同：<br>laravel框架不同于传统的MVC，传统的MVC请求一般直接对应的是控制器，laravel中的请求对应的是路由<br>laravel中的路由简单来说就是将用户的请求转发给相应的程序进行处理<br>作用就是建立URL和程序之间的映射<br>请求类型：get、post、put、patch、delete</p>
<h1 id="基本路由"><a href="#基本路由" class="headerlink" title="基本路由"></a>基本路由</h1><p>路径：<code>app/Http/routes.php</code>中定义应用中的大多数路由<br>该文件加载了<code>App\Providers\RouteServiceProvider</code>类</p>
<h3 id="GET路由"><a href="#GET路由" class="headerlink" title="GET路由"></a>GET路由</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">Route::get(&apos;/&apos;, function()</div><div class="line">&#123;</div><div class="line">    return &apos;Hello World&apos;;</div><div class="line">&#125;);</div></pre></td></tr></table></figure>
<h3 id="其它路由"><a href="#其它路由" class="headerlink" title="其它路由"></a>其它路由</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">Route::post(&apos;foo/bar&apos;, function()</div><div class="line">&#123;</div><div class="line">    return &apos;Hello World&apos;;</div><div class="line">&#125;);</div><div class="line"></div><div class="line">Route::put(&apos;foo/bar&apos;, function()</div><div class="line">&#123;</div><div class="line">    //</div><div class="line">&#125;);</div><div class="line"></div><div class="line">Route::delete(&apos;foo/bar&apos;, function()</div><div class="line">&#123;</div><div class="line">    //</div><div class="line">&#125;);</div></pre></td></tr></table></figure>
<h3 id="match请求注册多路由"><a href="#match请求注册多路由" class="headerlink" title="match请求注册多路由"></a>match请求注册多路由</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">Route::match([&apos;get&apos;, &apos;post&apos;], &apos;/&apos;, function()</div><div class="line">&#123;</div><div class="line">    return &apos;Hello World&apos;;</div><div class="line">&#125;);</div></pre></td></tr></table></figure>
<h3 id="any注册路由所有http请求"><a href="#any注册路由所有http请求" class="headerlink" title="any注册路由所有http请求"></a>any注册路由所有http请求</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">Route::any(&apos;foo&apos;, function()</div><div class="line">&#123;</div><div class="line">    return &apos;Hello World&apos;;</div><div class="line">&#125;);</div></pre></td></tr></table></figure>
<blockquote>
<p>路由产生 URL，可以使用 url 辅助函数来操作：<br>$url = url(‘foo’);</p>
</blockquote>
<h1 id="路由参数"><a href="#路由参数" class="headerlink" title="路由参数"></a>路由参数</h1><h3 id="基本路由参数"><a href="#基本路由参数" class="headerlink" title="基本路由参数"></a>基本路由参数</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">Route::get(&apos;user/&#123;id&#125;&apos;, function($id)</div><div class="line">&#123;</div><div class="line">    return &apos;User &apos;.$id;</div><div class="line">&#125;);</div></pre></td></tr></table></figure>
<blockquote>
<p>路由参数不能包含 - 字符。使用下划线替代 (_)。</p>
</blockquote>
<h3 id="可选择路由参数-带默认值参数"><a href="#可选择路由参数-带默认值参数" class="headerlink" title="可选择路由参数/带默认值参数"></a>可选择路由参数/带默认值参数</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">Route::get(&apos;user/&#123;name?&#125;&apos;, function($name = &apos;John&apos;)</div><div class="line">&#123;</div><div class="line">    return $name;</div><div class="line">&#125;);</div></pre></td></tr></table></figure>
<h3 id="使用正则表达式限制参数"><a href="#使用正则表达式限制参数" class="headerlink" title="使用正则表达式限制参数"></a>使用正则表达式限制参数</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">Route::get(&apos;user/&#123;id&#125;/&#123;name&#125;&apos;, function($id, $name)</div><div class="line">&#123;</div><div class="line">    //</div><div class="line">&#125;)</div><div class="line">-&gt;where([&apos;id&apos; =&gt; &apos;[0-9]+&apos;, &apos;name&apos; =&gt; &apos;[a-z]+&apos;]);</div></pre></td></tr></table></figure>
<h1 id="命名路由"><a href="#命名路由" class="headerlink" title="命名路由"></a>命名路由</h1><h3 id="使用as方便产生URL"><a href="#使用as方便产生URL" class="headerlink" title="使用as方便产生URL"></a>使用as方便产生URL</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">Route::get(&apos;user/profile&apos;, [&apos;as&apos; =&gt; &apos;profile&apos;, function()</div><div class="line">&#123;</div><div class="line">    return route(&apos;profile&apos;);</div><div class="line">&#125;]);</div></pre></td></tr></table></figure>
<h3 id="为控制器方法指定路由名称"><a href="#为控制器方法指定路由名称" class="headerlink" title="为控制器方法指定路由名称"></a>为控制器方法指定路由名称</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">Route::get(&apos;user/profile&apos;, [</div><div class="line">    &apos;as&apos; =&gt; &apos;profile&apos;, &apos;uses&apos; =&gt; &apos;UserController@showProfile&apos;</div><div class="line">]);</div></pre></td></tr></table></figure>
<h1 id="路由群组"><a href="#路由群组" class="headerlink" title="路由群组"></a>路由群组</h1><h3 id="Middleware"><a href="#Middleware" class="headerlink" title="Middleware"></a>Middleware</h3><p>在群组共享属性数组的 middleware 参数定义中间件列表，这些中间件就会应用到群组内的所有路由上。中间件将会按在列表内指定的顺序执行：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">Route::group([&apos;middleware&apos; =&gt; [&apos;foo&apos;, &apos;bar&apos;]], function()</div><div class="line">&#123;</div><div class="line">    Route::get(&apos;/&apos;, function()</div><div class="line">    &#123;</div><div class="line">        // Has Foo And Bar Middleware</div><div class="line">    &#125;);</div><div class="line"></div><div class="line">    Route::get(&apos;user/profile&apos;, function()</div><div class="line">    &#123;</div><div class="line">        // Has Foo And Bar Middleware</div><div class="line">    &#125;);</div><div class="line"></div><div class="line">&#125;);</div></pre></td></tr></table></figure>
<h3 id="Namespaces"><a href="#Namespaces" class="headerlink" title="Namespaces"></a>Namespaces</h3><p>可以在 group 属性数组中使用 namespace 参数，指定在这群组中控制器的命名空间：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">Route::group([&apos;namespace&apos; =&gt; &apos;Admin&apos;], function()</div><div class="line">&#123;</div><div class="line">    // Controllers Within The &quot;App\Http\Controllers\Admin&quot; Namespace</div><div class="line"></div><div class="line">    Route::group([&apos;namespace&apos; =&gt; &apos;User&apos;], function()</div><div class="line">    &#123;</div><div class="line">        // Controllers Within The &quot;App\Http\Controllers\Admin\User&quot; Namespace</div><div class="line">    &#125;);</div><div class="line">&#125;);</div></pre></td></tr></table></figure>
<blockquote>
<p>在默认情况下，RouteServiceProvider 包含内置您命名空间群组的 routes.php 文件，让您不须使用完整的 App\Http\Controllers 命名空间前缀就可以注册控制器路由。</p>
</blockquote>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/20160930-2.html" itemprop="url">
                  laravel - 安装laravel框架
                </a>
              
            
          </h1>
        

        <div class="post-meta">
        
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-09-30T14:43:24+08:00" content="2016-09-30">
              2016-09-30
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/20160930-2.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="20160930-2.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>Composer 安装 Laravel 有两种方式：</p>
<p>第一种是通过 Composer 的 create-project 命令安装 Laravel 框架，<br>第二种是先通过 Composer 安装 Laravel 安装器，然后通过安装器安装 Laravel 框架。</p>
<p>为什么 Composer 可以安装 Laravel 框架呢？</p>
<p>其实 Laravel框架也是一个 Composer包，我们可以通过如下命令查看：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div></pre></td><td class="code"><pre><div class="line">uiste:~ uiste$ composer show --all laravel/laravel</div><div class="line">No composer.json found in the current directory, showing available packages from packagist</div><div class="line">name     : laravel/laravel</div><div class="line">descrip. : The Laravel Framework.</div><div class="line">keywords : framework, laravel</div><div class="line">versions : dev-master, v5.3.10, v5.3.0, 5.2.x-dev, v5.2.31, v5.2.29, v5.2.27, v5.2.24, v5.2.23, v5.2.15, v5.2.0, 5.1.x-dev, v5.1.33, v5.1.11, v5.1.4, v5.1.3, v5.1.1, v5.1.0, 5.0.x-dev, v5.0.22, v5.0.16, v5.0.1, v5.0.0, v4.2.11, v4.2.0, v4.1.27, v4.1.18, v4.1.0, v4.0.9, v4.0.8, v4.0.7, v4.0.6, v4.0.5, v4.0.4, v4.0.0, v4.0.0-BETA4, v4.0.0-BETA3, dev-develop</div><div class="line">type     : project</div><div class="line">license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText</div><div class="line">source   : [git] https://github.com/laravel/laravel.git f4606d2bb94dc9579488df61fa3744b17e91be62</div><div class="line">dist     : [zip] https://packagist.phpcomposer.com/files/laravel/laravel/f4606d2bb94dc9579488df61fa3744b17e91be62.zip f4606d2bb94dc9579488df61fa3744b17e91be62</div><div class="line">names    : laravel/laravel</div><div class="line"></div><div class="line">autoload</div><div class="line">classmap</div><div class="line">database</div><div class="line">psr-4</div><div class="line">App\ =&gt; app/</div><div class="line"></div><div class="line">requires</div><div class="line">php &gt;=5.6.4</div><div class="line">laravel/framework 5.3.*</div><div class="line"></div><div class="line">requires (dev)</div><div class="line">fzaninotto/faker ~1.4</div><div class="line">mockery/mockery 0.9.*</div><div class="line">phpunit/phpunit ~5.0</div><div class="line">symfony/css-selector 3.1.*</div><div class="line">symfony/dom-crawler 3.1.*</div></pre></td></tr></table></figure>
<h2 id="create-project"><a href="#create-project" class="headerlink" title="create-project"></a>create-project</h2><p>第一种通过 Composer的 create-project 命令安装 Laravel 框架，</p>
<p><code>$ composer create-project laravel/laravel --prefer-dist [别名]</code></p>
<h2 id="Laravel-安装器"><a href="#Laravel-安装器" class="headerlink" title="Laravel 安装器"></a>Laravel 安装器</h2><p>第二种是先通过 Composer 安装 Laravel 安装器，然后通过安装器安装 Laravel 框架。</p>
<ol>
<li>使用 composer 全局安装 Laravel 安装器</li>
</ol>
<p><code>$ composer global require &quot;laravel/installer&quot;</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div></pre></td><td class="code"><pre><div class="line">uiste:~ uiste$ composer global require &quot;laravel/installer&quot;</div><div class="line">Changed current directory to /Users/uiste/.composer</div><div class="line">Using version ^1.3 for laravel/installer</div><div class="line">./composer.json has been updated</div><div class="line">Loading composer repositories with package information</div><div class="line">Updating dependencies (including require-dev)</div><div class="line">  - Installing symfony/process (v3.1.4)</div><div class="line">    Downloading: 100%         </div><div class="line"></div><div class="line">  - Installing symfony/polyfill-mbstring (v1.2.0)</div><div class="line">    Downloading: 100%         </div><div class="line"></div><div class="line">  - Installing symfony/console (v3.1.4)</div><div class="line">    Downloading: 100%         </div><div class="line"></div><div class="line">  - Installing guzzlehttp/promises (1.2.0)</div><div class="line">    Downloading: 100%         </div><div class="line"></div><div class="line">  - Installing psr/http-message (1.0.1)</div><div class="line">    Downloading: 100%         </div><div class="line"></div><div class="line">  - Installing guzzlehttp/psr7 (1.3.1)</div><div class="line">    Downloading: 100%         </div><div class="line"></div><div class="line">  - Installing guzzlehttp/guzzle (6.2.1)</div><div class="line">    Downloading: 100%         </div><div class="line"></div><div class="line">  - Installing laravel/installer (v1.3.4)</div><div class="line">    Downloading: 100%         </div><div class="line"></div><div class="line">symfony/console suggests installing symfony/event-dispatcher ()</div><div class="line">symfony/console suggests installing psr/log (For using the console logger)</div><div class="line">Writing lock file</div><div class="line">Generating autoload files</div></pre></td></tr></table></figure>
<ol>
<li>配置PATH环境变量</li>
</ol>
<p>将 <code>~/.composer/vendor/bin</code> 添加到 PATH 环境变量中，这样可执行文件 laravel 就能被你的系统检测到了。</p>
<p>编辑 <code>~/.bash_profile</code> 文件， <code>vim ~/.bash_profile</code> 加入如下代码：</p>
<p><code>export PATH=&quot;~/.composer/vendor/bin:$PATH&quot;</code></p>
<ol>
<li>检测是否配置成功</li>
</ol>
<p>新打开一个终端，输入如下命令：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">uiste:~ uiste$ laravel --version</div><div class="line">Laravel Installer version 1.3.3</div></pre></td></tr></table></figure>
<p>如果出现该信息，说明安装器已安装成功。</p>
<ol>
<li>安装Laravel</li>
</ol>
<p>打开终端，输入如下命令即可安装：</p>
<p>$ laravel new blog</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">uiste:~ uiste$ laravel new blog</div><div class="line"></div><div class="line">                               </div><div class="line">  [RuntimeException]           </div><div class="line">  Application already exists!  </div><div class="line">                               </div><div class="line"></div><div class="line">new [--dev] [--5.2] [--] [&lt;name&gt;]</div></pre></td></tr></table></figure>
<ol>
<li>安装最新的开发版本</li>
</ol>
<p>如果童鞋们对最新的开发版本比较感兴趣，可以下载进行测试，加上 –dev 参数即可：</p>
<p>$ laravel new demo –dev</p>
<hr>
<p>报错如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div></pre></td><td class="code"><pre><div class="line">uiste:~ uiste$ laravel new blog</div><div class="line">Crafting application...</div><div class="line">Loading composer repositories with package information</div><div class="line">Installing dependencies (including require-dev) from lock file</div><div class="line">Your requirements could not be resolved to an installable set of packages.</div><div class="line"></div><div class="line">  Problem 1</div><div class="line">    - This package requires php &gt;=5.6.4 but your PHP version (5.5.36) does not satisfy that requirement.</div><div class="line">  Problem 2</div><div class="line">    - Installation request for laravel/framework v5.3.15 -&gt; satisfiable by laravel/framework[v5.3.15].</div><div class="line">    - laravel/framework v5.3.15 requires php &gt;=5.6.4 -&gt; your PHP version (5.5.36) does not satisfy that requirement.</div><div class="line">  Problem 3</div><div class="line">    - Installation request for phpunit/php-code-coverage 4.0.1 -&gt; satisfiable by phpunit/php-code-coverage[4.0.1].</div><div class="line">    - phpunit/php-code-coverage 4.0.1 requires php ^5.6 || ^7.0 -&gt; your PHP version (5.5.36) does not satisfy that requirement.</div><div class="line">  Problem 4</div><div class="line">    - Installation request for phpunit/phpunit 5.5.5 -&gt; satisfiable by phpunit/phpunit[5.5.5].</div><div class="line">    - phpunit/phpunit 5.5.5 requires php ^5.6 || ^7.0 -&gt; your PHP version (5.5.36) does not satisfy that requirement.</div><div class="line">  Problem 5</div><div class="line">    - Installation request for phpunit/phpunit-mock-objects 3.2.7 -&gt; satisfiable by phpunit/phpunit-mock-objects[3.2.7].</div><div class="line">    - phpunit/phpunit-mock-objects 3.2.7 requires php ^5.6 || ^7.0 -&gt; your PHP version (5.5.36) does not satisfy that requirement.</div><div class="line">  Problem 6</div><div class="line">    - Installation request for sebastian/code-unit-reverse-lookup 1.0.0 -&gt; satisfiable by sebastian/code-unit-reverse-lookup[1.0.0].</div><div class="line">    - sebastian/code-unit-reverse-lookup 1.0.0 requires php &gt;=5.6 -&gt; your PHP version (5.5.36) does not satisfy that requirement.</div><div class="line">  Problem 7</div><div class="line">    - Installation request for sebastian/object-enumerator 1.0.0 -&gt; satisfiable by sebastian/object-enumerator[1.0.0].</div><div class="line">    - sebastian/object-enumerator 1.0.0 requires php &gt;=5.6 -&gt; your PHP version (5.5.36) does not satisfy that requirement.</div><div class="line">  Problem 8</div><div class="line">    - Installation request for sebastian/resource-operations 1.0.0 -&gt; satisfiable by sebastian/resource-operations[1.0.0].</div><div class="line">    - sebastian/resource-operations 1.0.0 requires php &gt;=5.6.0 -&gt; your PHP version (5.5.36) does not satisfy that requirement.</div><div class="line">  Problem 9</div><div class="line">    - Installation request for sebastian/version 2.0.0 -&gt; satisfiable by sebastian/version[2.0.0].</div><div class="line">    - sebastian/version 2.0.0 requires php &gt;=5.6 -&gt; your PHP version (5.5.36) does not satisfy that requirement.</div><div class="line"></div><div class="line">Application ready! Build something amazing.</div></pre></td></tr></table></figure>
<h2 id="Mac-OS-X-升级PHP版本"><a href="#Mac-OS-X-升级PHP版本" class="headerlink" title="Mac OS X 升级PHP版本"></a>Mac OS X 升级PHP版本</h2><h3 id="方法一："><a href="#方法一：" class="headerlink" title="方法一："></a>方法一：</h3><ol>
<li>查询本机PHP版本</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">uiste:~ uiste$ php -v</div><div class="line">PHP 5.5.36 (cli) (built: May 29 2016 01:07:06) </div><div class="line">Copyright (c) 1997-2015 The PHP Group</div><div class="line">Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies</div></pre></td></tr></table></figure>
<ol>
<li>然后我们根据实际需求去升级</li>
</ol>
<p><code>curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6.4</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div></pre></td><td class="code"><pre><div class="line">uiste:~ uiste$ curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6.4</div><div class="line">Detected OS X El Capitan 10.11. All ok.</div><div class="line">Get packager.tgz</div><div class="line">Unpack packager.tgz</div><div class="line">Please type in your password, as we want to install this into /usr/local</div><div class="line"></div><div class="line">WARNING: Improper use of the sudo command could lead to data loss</div><div class="line">or the deletion of important system files. Please double-check your</div><div class="line">typing when using sudo. Type &quot;man sudo&quot; for more information.</div><div class="line"></div><div class="line">To proceed, enter your password, or type Ctrl-C to abort.</div><div class="line"></div><div class="line">Password:</div><div class="line">Start packager (may take some time)</div><div class="line">downloading https://s3-eu-west-1.amazonaws.com/php-osx.liip.ch/install/5.6.4-frontenddev-latest.dat</div><div class="line">downloading https://s3-eu-west-1.amazonaws.com/php-osx.liip.ch/&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div class="line"></div><div class="line">downloading https://s3-eu-west-1.amazonaws.com/php-osx.liip.ch/5.6.4-frontenddev.tar.bz2</div><div class="line">downloading https://s3-eu-west-1.amazonaws.com/php-osx.liip.ch/5.6.4-frontenddev.tar.gz</div><div class="line">downloading https://s3-eu-west-1.amazonaws.com/php-osx.liip.ch/5.6.4-frontenddev.tgz</div><div class="line">Did or could not download package: 5.6.4-frontenddev</div></pre></td></tr></table></figure>
<blockquote>
<p>中途会提示你输入密码，下载的 PHP 会放置到 /usr/local 下，但不会覆盖原系统 PHP<br>如上所升级的 5.5，PHP 会位于 /usr/local/php5 中，并自动链接到 /etc/apache2/ 下的配置文件<br>然后再新建一个 PHP 文件，写上 phpinfo(); 浏览器访问看看，版本已经升级。</p>
</blockquote>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/3/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/3/">3</a><span class="page-number current">4</span><a class="page-number" href="/page/5/">5</a><span class="space">&hellip;</span><a class="page-number" href="/page/14/">14</a><a class="extend next" rel="next" href="/page/5/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      

      <section class="site-overview sidebar-panel  sidebar-panel-active ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.png"
               alt="uiste" />
          <p class="site-author-name" itemprop="name">uiste</p>
          <p class="site-description motion-element" itemprop="description">Stay Hungry，Stay Foolish</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">70</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              
                <span class="site-state-item-count">13</span>
                <span class="site-state-item-name">分类</span>
              
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">55</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/uiste" target="_blank" rel="external nofollow" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/uiste" target="_blank" rel="external nofollow" title="微博">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  微博
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.zhihu.com/people/uiste" target="_blank" rel="external nofollow" title="知乎">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  知乎
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              友情链接
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.uiste.com" title="uiste 个人博客" target="_blank">uiste 个人博客</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://uiste.github.io" title="uiste 技术博客" target="_blank">uiste 技术博客</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 - 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">uiste</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="http://hexo.io" rel="external nofollow">Hexo</a> 趋势动力
</div>
<!--站长统计-->
<script src="https://s95.cnzz.com/z_stat.php?id=1259894121&web_id=1259894121" language="JavaScript"></script>
<!--<div class="theme-info">
  Theme -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next" rel="external nofollow">
    NexT.Mist
  </a>
</div> -->
&nbsp;&nbsp;&nbsp;本站总点击 <span id="busuanzi_value_site_pv"></span> 次
&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;您是第 <span id="busuanzi_value_site_uv"></span> 位访客

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>

<script>
(function(){
    var bp = document.createElement('script');
    bp.src = '//push.zhanzhang.baidu.com/push.js';
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  

  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"uiste"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    <script src="/vendors/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  






  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
       search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();

    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
    'use strict';
    $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
            // get the contents from search data
            isfetched = true;
            $('.popup').detach().appendTo('.header-inner');
            var datas = $( "entry", xmlResponse ).map(function() {
                return {
                    title: $( "title", this ).text(),
                    content: $("content",this).text(),
                    url: $( "url" , this).text()
                };
            }).get();
            var $input = document.getElementById(search_id);
            var $resultContent = document.getElementById(content_id);
            $input.addEventListener('input', function(){
                var matchcounts = 0;
                var str='<ul class=\"search-result-list\">';
                var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                $resultContent.innerHTML = "";
                if (this.value.trim().length > 1) {
                // perform local searching
                datas.forEach(function(data) {
                    var isMatch = true;
                    var content_index = [];
                    var data_title = data.title.trim().toLowerCase();
                    var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                    var data_url = data.url;
                    var index_title = -1;
                    var index_content = -1;
                    var first_occur = -1;
                    // only match artiles with not empty titles and contents
                    if(data_title != '' && data_content != '') {
                        keywords.forEach(function(keyword, i) {
                            index_title = data_title.indexOf(keyword);
                            index_content = data_content.indexOf(keyword);
                            if( index_title < 0 && index_content < 0 ){
                                isMatch = false;
                            } else {
                                if (index_content < 0) {
                                    index_content = 0;
                                }
                                if (i == 0) {
                                    first_occur = index_content;
                                }
                            }
                        });
                    }
                    // show search results
                    if (isMatch) {
                        matchcounts += 1;
                        str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                        var content = data.content.trim().replace(/<[^>]+>/g,"");
                        if (first_occur >= 0) {
                            // cut out 100 characters
                            var start = first_occur - 20;
                            var end = first_occur + 80;
                            if(start < 0){
                                start = 0;
                            }
                            if(start == 0){
                                end = 50;
                            }
                            if(end > content.length){
                                end = content.length;
                            }
                            var match_content = content.substring(start, end);
                            // highlight all keywords
                            keywords.forEach(function(keyword){
                                var regS = new RegExp(keyword, "gi");
                                match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                            });

                            str += "<p class=\"search-result\">" + match_content +"...</p>"
                        }
                        str += "</li>";
                    }
                })};
                str += "</ul>";
                if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
                if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
                $resultContent.innerHTML = str;
            });
            proceedsearch();
        }
    });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };

    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>


  

  

  

</body>
</html>
